Socket
Socket
Sign inDemoInstall

gunzip-maybe

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gunzip-maybe

Transform stream that gunzips its input if it is gzipped and just echoes it if not


Version published
Weekly downloads
2.9M
decreased by-6.4%
Maintainers
2
Weekly downloads
 
Created

What is gunzip-maybe?

The 'gunzip-maybe' npm package is a utility for conditionally decompressing gzip files. It is particularly useful in streams where you may not know if the input is gzipped or not. The package will automatically detect and decompress gzipped input, passing through non-gzipped input unchanged.

What are gunzip-maybe's main functionalities?

Conditional Decompression

This feature allows you to conditionally decompress a file if it is gzipped. The code sample reads a potentially gzipped file ('file.txt.gz') and writes the decompressed content to 'file.txt'. If the input file is not gzipped, it simply passes the content through unchanged.

const fs = require('fs');
const gunzipMaybe = require('gunzip-maybe');

fs.createReadStream('file.txt.gz')
  .pipe(gunzipMaybe())
  .pipe(fs.createWriteStream('file.txt'));

Stream Processing

This feature demonstrates how 'gunzip-maybe' can be used in a stream processing pipeline. The code sets up a PassThrough stream, pipes it through 'gunzip-maybe', and then pipes the result to another PassThrough stream. This allows for flexible stream processing where the input may or may not be gzipped.

const { PassThrough } = require('stream');
const gunzipMaybe = require('gunzip-maybe');

const input = new PassThrough();
const output = new PassThrough();

input.pipe(gunzipMaybe()).pipe(output);

input.write('some data');
input.end();

output.on('data', (data) => {
  console.log(data.toString());
});

Other packages similar to gunzip-maybe

FAQs

Package last updated on 22 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc